package com.linkhub.oms.data.sync.api.yunexpress.domain.response;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @Description: 创建运单响应
 * @Author: Jaycle
 * @Date: 2024/06/30 16:41
 * @Version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class CreateOrderResponse extends YunExpressBaseResponse implements Serializable {

    @JSONField(serialize = false, deserialize = false)
    public boolean success() {
        return SUCCESS_CODE.equals(getCode()) && items != null && !items.isEmpty();
    }

    @JSONField(name = "Item")
    private List<Item> items;

    /**
     * code
     */
    @JSONField(name = "Code")
    private String code;

    /**
     * message
     */
    @JSONField(name = "Message")
    private String message;

    /**
     * requestId
     */
    @JSONField(name = "RequestId")
    private String requestId;

    /**
     * timeStamp
     */
    @JSONField(name = "TimeStamp")
    private String timeStamp;

    /**
     * Item
     */
    @NoArgsConstructor
    @Data
    public static class Item {
        @JSONField(serialize = false, deserialize = false)
        public boolean success() {
            return ITEM_SUCCESS_CODE.equals(getSuccess());
        }
        /**
         * customerOrderNumber
         */
        @JSONField(name = "CustomerOrderNumber")
        private String customerOrderNumber;

        /**
         * success
         */
        @JSONField(name = "Success")
        private Integer success;

        /**
         * trackType
         */
        @JSONField(name = "TrackType")
        private String trackType;

        /**
         * remark
         */
        @JSONField(name = "Remark")
        private String remark;

        /**
         * agentNumber
         */
        @JSONField(name = "AgentNumber")
        private String agentNumber;

        /**
         * wayBillNumber
         */
        @JSONField(name = "WayBillNumber")
        private String wayBillNumber;

        /**
         * requireSenderAddress
         */
        @JSONField(name = "RequireSenderAddress")
        private Integer requireSenderAddress;

        /**
         * trackingNumber
         */
        @JSONField(name = "TrackingNumber")
        private String trackingNumber;

        /**
         * shipperBoxs
         */
        @JSONField(name = "ShipperBoxs")
        private List<ShipperBox> shipperBoxs;

        /**
         * ShipperBox
         */
        @NoArgsConstructor
        @Data
        public static class ShipperBox {
            /**
             * boxNumber
             */
            @JSONField(name = "BoxNumber")
            private String boxNumber;

            /**
             * shipperHawbcode
             */
            @JSONField(name = "ShipperHawbcode")
            private String shipperHawbcode;
        }
    }
}
